// pages/ckjzr/ckjzr.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
  list_jzr:[
    {
        id:'0',
        name:'谢文婷',
        sex:'1',
        cardnum:'420117201202568525',
        telephone:'18569458623',
        jws: '无遗传疾病'
    },
    {
        id:'1',
        name:'肖雨婷',
        sex:'1',
        cardnum:'96585',
        telephone:'456',
        jws: '换季容易感冒'
    },
    {
        id:'2',
        name:'张洋嘉',
        sex:'0',
        cardnum:'56568',
        telephone:'678',
        jws: '无遗传疾病'
    }
  ],
  list:{
      id:'0',
      name:'谢文婷',
      sex:'1',
      cardnum:'12560',
      telephone:'123',
      jws: '无遗传疾病'
  },
    currentTab: 0 ,// 选项卡默认位置
    sex:['男','女'],
    userName:'',
    userCard:'',
    userSex:'',
    userPhone:''
  },

      /**
   * 退回上一页
   */
  toBackClick: function() {
    wx.navigateBack({})
  },
   /**
   * 点击tab菜单切换
   * @param {} e 
   */
  changeSwiperTab: function (e) {
    var _this = this;
    var id = e.currentTarget.dataset.current;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      _this.setData({
        currentTab: e.target.dataset.current,
        list: this.data.list_jzr[id]
      })
    }
    console.log(e);
    console.log(this.data.list)
  },

  /**
   * 跳转
   */
  tjjzr:function(){
    wx.navigateTo({
      url: '../tjjzr/tjjzr'
    })
  },

 /**
   * 传值的，不要就删了
   */
  onLoad: function (options) {
    var that = this
    wx.getStorage({
      key: 'userName',
      success: function(res) {
        that.setData({ userName: res.data })
      },
    })
    wx.getStorage({
      key: 'userCard',
      success: function (res) {
        that.setData({ userCard: res.data })
      },
    })
    wx.getStorage({
      key: 'userSex',
      success: function (res) {
        if(res.data=='1')
        that.setData({userSex: '女'})
        if(res.data=='0')
        that.setData({userSex: '男'})
      },
    })
    wx.getStorage({
      key: 'userPhone',
      success: function (res) {
        that.setData({ userPhone: res.data })
      },
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {/** 确实是放进数组了，但还是有bug*/
    var that = this
    var jzr = that.data.list_jzr
    console.log(that.data.list_jzr)
    console.log(that.data.userName)
    jzr.push(that.data.userName);
    //that.setData({ list_jzr: jzr })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

})